package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

func main() {
	//测试通过redigo连接redis
	conn, _ := redis.Dial("tcp", "localhost:6379")
	defer conn.Close()

	//Send方法将命令加入缓冲区待执行
	conn.Send("set", "k1", "v1")
	conn.Send("set", "k2", "v2")
	conn.Send("get", "k2")
	//Flush方法清除缓冲区并一并执行发送命令
	conn.Flush()

	//Receive方法按照FIFO顺序接受执行命令的返回
	ret, _ := conn.Receive()
	fmt.Println(ret)
	ret, _ = conn.Receive()
	fmt.Println(ret)
	ret, err := conn.Receive()
	fmt.Println(redis.String(ret, err))
}
